﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Admin_Master.master" AutoEventWireup="true" CodeFile="product.aspx.cs" Inherits="admin_product" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <ul id="top-navigation">
       
        <li><span><span><a href="user.aspx">Users</a></span></span></li>
        <li class="active"><span><span><a href="product.aspx">Products</a></span></span></li>
        <li><span><span><a href="category.aspx">Category</a></span></span></li>
        <li><span><span><a href="order.aspx">Orders</a></span></span></li>
        
    </ul>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="top-bar">
        <a href="#Add" style="float: left; background-color: blue; padding: 4px; color: white; font-weight: bold;">ADD NEW </a>
    </div>
    <br />
    <div class="select-bar">
        <label>
            <asp:TextBox ID="txtSearchProduct" runat="server"></asp:TextBox>
        </label>
        <label>
            <asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click"  />
        </label>
    </div>
    <div class="table">


        <!-- gridView sản phẩm-->
        <asp:GridView ID="gvProduct" runat="server" AutoGenerateColumns="False"  AllowPaging="True" OnPageIndexChanging="gvProduct_PageIndexChanging" PageSize="5" OnRowDeleting="gvProduct_RowDeleting">
            <Columns>
                <asp:TemplateField HeaderText="Product Name" SortExpression="ProName">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtProName" runat="server" Text='<%# Bind("ProName") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblProId" runat="server" Text='<%# Bind("ProId") %>' Visible="False"></asp:Label>
                        <asp:Label ID="lblProName" runat="server" Text='<%# Bind("ProName") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleProduct" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleProduct" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Category" SortExpression="CateName">
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlCategory" runat="server"></asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCateName" runat="server" Text='<%# Bind("CateName") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleCate" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleCate" />
                </asp:TemplateField>


                <asp:TemplateField HeaderText="Price" SortExpression="Price">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtPrice" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblPrice" runat="server" Text='<%# Bind("Price") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleHeader" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleShort" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Quan" SortExpression="Quantity">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtQuantity" runat="server" Text='<%# Bind("Quantity") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblQuantity" runat="server" Text='<%# Bind("Quantity") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleShortShort" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleShortShort" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="IsSale" SortExpression="IsSale">
                    <EditItemTemplate>
                        <asp:CheckBox ID="chbxIsSaleItemEdit" runat="server" Checked='<%# Bind("IsSale") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbxIsSaleItem" runat="server" Checked='<%# Bind("IsSale") %>' Enabled="False" />
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleShortShort" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleShortShort" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Delete" ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbtDelete" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleCommand" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleCommand" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Update" SortExpression="Update">
                    <ItemTemplate>
                        <asp:HyperLink ID="LinkUpdate" runat="server" NavigateUrl='<%# "DetailProduct.aspx?command=update&proid=" + Eval("ProId")%> '>Update</asp:HyperLink>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleCommand" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleCommand" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Detail" SortExpression="Detail">
                    <ItemTemplate>
                        <asp:HyperLink ID="LinkDetail" runat="server" NavigateUrl='<%# "DetailProduct.aspx?command=detail&proid=" + Eval("ProId")%> '>Detail</asp:HyperLink>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" CssClass="StyleCommand" />
                    <ItemStyle HorizontalAlign="Center" CssClass="StyleCommand" />
                </asp:TemplateField>

            </Columns>
            <FooterStyle BackColor="Tan" />
            <HeaderStyle BackColor="#9097A9" Font-Bold="True" Width="100px" ForeColor="White" Height="30" />
            <PagerStyle BackColor="#9097A9" ForeColor="White" HorizontalAlign="Center" Font-Size="13" />
            <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="White" />
            <RowStyle BackColor="#D8D8D8" ForeColor="black" />
            <SortedAscendingCellStyle BackColor="#FAFAE7" />
            <SortedAscendingHeaderStyle BackColor="#DAC09E" />
            <SortedDescendingCellStyle BackColor="#E1DB9C" />
            <SortedDescendingHeaderStyle BackColor="#C2A47B" />
        </asp:GridView>
        <br />
        <a name="Add"></a>
        <img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />

        <!-- Add product -->
        <table class="listing form" cellpadding="0" cellspacing="0">
            <tr>
                <th class="full" colspan="2">Add  a new product</th>

            </tr>
            <tr>
                <td class="first" width="172"><strong>Product Name: </strong></td>
                <td class="last">
                     <asp:TextBox ID="txtProName" runat="server" Width="262"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Ph&#7843;i nh&#7853;p tên c&#7911;a s&#7843;n ph&#7849;m" ControlToValidate="txtProName" ValidationGroup="AddProduct" CssClass="error"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr class="bg">
                <td class="first"><strong>Category:</strong></td>
                <td class="last">
                    <asp:DropDownList ID="ddlCategory" runat="server"  Width="266px"></asp:DropDownList> </td>
            </tr>
            <tr class="bg">
                <td class="first"><strong>Price:</strong></td>  
                <td class="last">  
                    <asp:TextBox ID="txtprice" runat="server" Width="262"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"  CssClass="error" ErrorMessage="Ph&#7843;i nh&#7853;p giá c&#7911;a s&#7843;n ph&#7849;m" ControlToValidate="txtPrice" ValidationGroup="AddProduct" Display="Dynamic" ></asp:RequiredFieldValidator>
                    <asp:RangeValidator ID="RangeValidator2" runat="server"  CssClass="error" ErrorMessage="Ph&#7843;i là s&#7889; nguyên >0" ControlToValidate="txtprice" Type="Integer" MinimumValue="1" MaximumValue="10000000"  Display="Dynamic"  ValidationGroup="AddProduct"></asp:RangeValidator>
                </td>
            </tr>
            <tr class="bg">
                <td class="first"><strong>Quantity:</strong></td>
    
                <td class="last">  
                    <asp:TextBox ID="txtQuantityAdd" runat="server" Width="262" ></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" CssClass="error" ErrorMessage="Ph&#7843;i nh&#7853;p s&#7889; l&#432;&#7907;ng s&#7843;n phâm(>0 và <100,000)" Display="Dynamic" ControlToValidate="txtQuantityAdd" ValidationGroup="AddProduct"></asp:RequiredFieldValidator>
                    <asp:RangeValidator ID="RangeValidator1" runat="server" CssClass="error" ErrorMessage="Ph&#7843;i là s&#7889; nguyên >0 và <100,000" ControlToValidate="txtQuantityAdd" Type="Integer" MinimumValue="1" MaximumValue="100000"  Display="Dynamic"></asp:RangeValidator>
                </td>
            </tr>
            <tr class="bg">
                <td class="first"><strong>IsSale </strong></td>
                <td class="last"><asp:CheckBox ID="chbxIsSale" runat="server" /> </td>
            </tr>
           
            <tr class="bg">
                <td class="first"><strong>Image:</strong></td>
                <td class="last" >
                    <asp:FileUpload ID="UploadFile" runat="server" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" CssClass="error" ErrorMessage="Ph&#7843;i ch&#7885;n &#7843;nh cho s&#7843;n ph&#7849;m" ValidationGroup="AddProduct" ControlToValidate="UploadFile"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr class="bg">
                <td class="first"><strong>Content:</strong></td>
                <td class="last">
                    <asp:TextBox ID="txtContent" runat="server" Rows="20" TextMode="MultiLine" Width="710"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="first"></td>
                <td class="last">
                    <asp:Button ID="txtAddProduct" runat="server" Text="Add" CssClass="button1" OnClick="txtAddProduct_Click"  ValidationGroup="AddProduct" />
                    <input id="Reset1" type="reset" value="Reset" class="button1" />
                </td>
            </tr>
        </table>
        <p>
            &nbsp;
        </p>

    </div>





</asp:Content>

